package com.purdueacm.sigapp.seminar2;

import android.app.Activity;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class Main extends Activity {
    /** Called when the activity is first created. */
	
	EditText username;
	EditText password;
	TextView textView;
	CheckBox cb;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        LinearLayout layout = (LinearLayout)findViewById(R.id.layout);
        password = new EditText(this);
        password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD );
        layout.addView(password);
        username = (EditText)findViewById(R.id.username);
        textView  = (TextView)findViewById(R.id.textView2);
        
        cb = (CheckBox)findViewById(R.id.checkBox1);
        Button b = (Button)findViewById(R.id.button1);
//        b.setOnClickListener(new OnClickListener(){
//			@Override
//			public void onClick(View arg0) {
//				if(checkPassword(username.getEditableText().toString(),password.getEditableText().toString())){
//					Toast.makeText(Main.this, "You have been logged in!", Toast.LENGTH_SHORT).show();
//					textView.setText("You are logged in!");
//				}
//				if(cb.isChecked()){
//					Toast.makeText(Main.this, "YYou will be remembered!", Toast.LENGTH_SHORT).show();
//				}
//			}
//        });
        
    }
    
    public void login(View v){
		if(checkPassword(username.getEditableText().toString(),password.getEditableText().toString())){
			Toast.makeText(Main.this, "You have been logged in!", Toast.LENGTH_SHORT).show();
			textView.setText("You are logged in!");
		}
		if(cb.isChecked()){
			Toast.makeText(Main.this, "YYou will be remembered!", Toast.LENGTH_SHORT).show();
		}
    }
    
    public boolean checkPassword(String username, String password){
    	if(username.equals("username") && password.equals("password")){
    		return true;
    	}
    	return false;
    }
}